package com.zhongyu.consumer.controller;

import com.zhongyu.comm.vo.CommentVo;
import com.zhongyu.comm.vo.Result;
import com.zhongyu.consumer.service.CommentClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentClient commentClient;

    @RequestMapping("/add")
    public Result add(@RequestBody CommentVo commentVo){
        try{
            commentClient.add1(commentVo);
            return Result.success("添加评论成功");
        }catch (Exception e){
            return Result.fail("添加评论失败");
        }
    }
    @RequestMapping("/addcom")
    public Result addcom(CommentVo commentVo){   //采用x-www-form-urlencoded @RequestParam不可以写
        try{
            commentClient.add1(commentVo);
            return Result.success("添加评论成功addcom");
        }catch (Exception e){
            return Result.fail("添加评论失败addcom");
        }
    }
}
